﻿CREATE FUNCTION dbo._ObjectExists
( @ObjectName sysname
)RETURNS bit
AS BEGIN

DECLARE @Ret bit 

IF @ObjectName LIKE '#%'
	select @Ret = COUNT(*) from tempdb..sysobjects where name like @ObjectName+'%'
ELSE 
	select @Ret = COUNT(*) from sysobjects where id = object_id(@ObjectName)

RETURN @Ret
END
